<style lang="scss" scoped>
.mysample {
  .topbar {
    .rightbtn {
      .api {
        p {
          color: #ffffff;
          font-size: 0.14rem;
          line-height: 0.4rem;
          text-align: center;
          span {
            margin-left: 0.1rem;
          }
          border-bottom: 0.01rem solid #ffffff;
        }
      }
    }
  }
  .sample-list {
    padding-top: 0.44rem;
    .el-table {
      font-size: 0.16rem;
    }
  }
}
</style>

<template>
    <div class="mysample">
        <div class="topbar">
            <span class="leftbtn" @click="goback"><Icon type="ios-arrow-back"></Icon></span>
            <span class="centertitle">我的样本</span>
            <span class="rightbtn">
                <Tooltip placement="bottom-end">
                    <!-- <a style="cursor:pointer;">筛选</a>                    -->
                    <Icon type="android-menu"></Icon>
                    <div class="api" slot="content">
                        <p @click="getGeneticTumorList">
                            <span >遗传性肿瘤</span>                        
                        </p>
                        <p @click="getRareList">
                            <span>单基因遗传病</span>
                        </p> 
                        <p @click="getBodyCellList">
                            <span >肿瘤个体化用药</span>
                        </p>                         
                    </div>
                </Tooltip>    
            </span>
        </div>        
        <div class="sample-list">
            <el-table :data="sampleList" @row-click="dblclick" >
                <el-table-column  label="姓名" prop="name"></el-table-column>
                 <el-table-column label="样本编号" prop="sampleNum"></el-table-column>
                <el-table-column label="检测项目" prop="testType" ></el-table-column>
                <el-table-column label="金额" prop="monney"></el-table-column>
                 <el-table-column label="录入人" prop="username"></el-table-column>
                <!-- <el-table-column label="状态" prop="sampleState"></el-table-column> -->
            </el-table>
        </div>      
    </div>
</template>

<script>
import { sampleData } from "api/index.js";
import { setCookie, getCookie, delCookie } from "common/js/cookie.js";
import { defaultCoreCipherList } from "constants";
export default {
  name: "mySample",
  data() {
    return {
      sampleList: []
    };
  },
  methods: {
    goback() {
      this.$router.push("/index");
    },
    getGeneticTumorList() {
      this.tipDisabled = true;
      this.$store.state.currentCatalog = "geneticTumor";
      let obj = {
        //  token:getCookie('token')
      };
      sampleData
        .getGeneticTumorList()
        .then(res => {
          if (res.code == 0 || res.code == 200) {
            this.sampleList = res.list;
          } else {
            this.$Message.error(res.msg);
          }
        })
        .catch(error => {
          this.$Message.error(error);
        });
    },
    getRareList() {
      this.$store.state.currentCatalog = "rare";
      let obj = {
        //  token:getCookie('token')
      };
      sampleData
        .getRareList()
        .then(res => {
          if (res.code == 0 || res.code == 200) {
            this.sampleList = res.list;
          } else {
            this.$Message.error(res.msg);
          }
        })
        .catch(error => {
          this.$Message.error(error);
        });
    },
    getBodyCellList() {
      this.$store.state.currentCatalog = "bodyCell";
      let obj = {};
      sampleData
        .getBodyCellList(obj)
        .then(res => {
          if (res.code == 0 || res.code == 200) {
            this.sampleList = res.list;
          } else {
            this.$Message.error(res.msg);
          }
        })
        .catch(error => {
          this.$Message.error(error);
        });
    },
    dblclick(row) {
      this.$store.state.sampleid = row.id;
      switch (row.sampleType) {
        case 0:
          this.$store.state.currentCatalog = "geneticTumor";
          break;
        case 1:
          this.$store.state.currentCatalog = "rare";
          break;
        case 2:
          this.$store.state.currentCatalog = "bodyCell";
          break;
        default:
          break;
      }
      switch (this.$store.state.currentCatalog) {
        case "geneticTumor":
          this.$store.state.operation = "edit";
          this.$router.push("/geneticTumor");
          break;
        case "rare":
          this.$store.state.operation = "edit";
          this.$router.push("/rareInfo");
          break;
        case "bodyCell":
          this.$store.state.operation = "edit";
          this.$router.push("/bodyCell");
          break;
        default:
          break;
      }
      this.$store.state.btnTemp=false;
    },
    getAllList() {
      sampleData
        .getAllList()
        .then(res => {
          if (res.code == 0 || res.code == 200) {
            this.sampleList = res.list;
          }else {
            this.$Message.error(res.msg);
          }
        })
        .catch(error => {
          this.$Message.error(error);
        });
    }
  },
  mounted() {
    this.getAllList();
  }
};
</script>

